package com.thysdy.flowable.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.thysdy.flowable.entity.ActIdUser;
import com.thysdy.flowable.enums.CodeEnum;
import com.thysdy.flowable.exception.MyException;
import com.thysdy.flowable.mapper.ActIdUserMapper;
import com.thysdy.flowable.service.IActIdUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ML
 * @since 2020-09-14
 */
@Service
@Slf4j
public class ActIdUserServiceImpl extends ServiceImpl<ActIdUserMapper, ActIdUser> implements IActIdUserService {

    @Override
    public void addUser(ActIdUser user) throws MyException {
        try {
            if (null != user) {
                save(user);
            } else {
                throw new MyException(CodeEnum.paramError);
            }
        } catch (MyException e) {
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("addUser error!", e);
            throw new MyException(CodeEnum.commonException);
        }
    }

    @Override
    public void updateUser(ActIdUser user) throws MyException {
        try {
            if (null != user&&null!=user.getId()) {
                updateById(user);
            } else {
                throw new MyException(CodeEnum.paramError);
            }
        } catch (MyException e) {
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("updateUser error!", e);
            throw new MyException(CodeEnum.commonException);
        }
    }
}
